﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using Maticsoft.Common;
 
namespace StuEdu.Web.GradeInfo
{
    public partial class Modify : Page
    {       

        		protected void Page_Load(object sender, EventArgs e)
		{
			if (!Page.IsPostBack)
			{
				if (Request.Params["id"] != null && Request.Params["id"].Trim() != "")
				{
					int gradeInfoId=(Convert.ToInt32(Request.Params["id"]));
					ShowInfo(gradeInfoId);
				}
			}
		}
			
	private void ShowInfo(int gradeInfoId)
	{
		StuEdu.BLL.GradeInfo bll=new StuEdu.BLL.GradeInfo();
		StuEdu.Model.GradeInfo model=bll.GetModel(gradeInfoId);
		this.lblgradeInfoId.Text=model.gradeInfoId.ToString();
		this.txtgradeName.Text=model.gradeName;
		this.txtgradeMaster.Text=model.gradeMaster;
		this.txtgradeTime.Text=model.gradeTime.ToString();

	}

		public void btnSave_Click(object sender, EventArgs e)
		{
			
			string strErr="";
			if(this.txtgradeName.Text.Trim().Length==0)
			{
				strErr+="gradeName不能为空！\\n";	
			}
			if(this.txtgradeMaster.Text.Trim().Length==0)
			{
				strErr+="gradeMaster不能为空！\\n";	
			}
			if(!PageValidate.IsDateTime(txtgradeTime.Text))
			{
				strErr+="gradeTime格式错误！\\n";	
			}

			if(strErr!="")
			{
				MessageBox.Show(this,strErr);
				return;
			}
			int gradeInfoId=int.Parse(this.lblgradeInfoId.Text);
			string gradeName=this.txtgradeName.Text;
			string gradeMaster=this.txtgradeMaster.Text;
			DateTime gradeTime=DateTime.Parse(this.txtgradeTime.Text);


			StuEdu.Model.GradeInfo model=new StuEdu.Model.GradeInfo();
			model.gradeInfoId=gradeInfoId;
			model.gradeName=gradeName;
			model.gradeMaster=gradeMaster;
			model.gradeTime=gradeTime;

			StuEdu.BLL.GradeInfo bll=new StuEdu.BLL.GradeInfo();
			bll.Update(model);
			Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功！","list.aspx");

		}


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("list.aspx");
        }
    }
}
